package org.ruoyi.interview.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.ruoyi.interview.mapper.InterviewConversationMapper;
import org.ruoyi.interview.domain.InterviewConversation;
import org.ruoyi.interview.service.IInterviewConversationService;
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
import org.ruoyi.common.mybatis.core.page.PageQuery;

/**
 * 对话记录Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class InterviewConversationServiceImpl extends ServiceImpl<InterviewConversationMapper, InterviewConversation> implements IInterviewConversationService {

    @Autowired
    private InterviewConversationMapper interviewConversationMapper;

    /**
     * 查询对话记录
     * 
     * @param conversationId 对话记录主键
     * @return 对话记录
     */
    @Override
    public InterviewConversation selectInterviewConversationById(Long conversationId) {
        return interviewConversationMapper.selectById(conversationId);
    }

    /**
     * 查询对话记录列表
     * 
     * @param interviewConversation 对话记录
     * @param pageQuery 分页参数
     * @return 对话记录集合
     */
    @Override
    public TableDataInfo<InterviewConversation> selectInterviewConversationList(InterviewConversation interviewConversation, PageQuery pageQuery) {
        LambdaQueryWrapper<InterviewConversation> lqw = Wrappers.lambdaQuery();
        lqw.eq(interviewConversation.getUserId() != null, InterviewConversation::getUserId, interviewConversation.getUserId());
        lqw.like(interviewConversation.getTitle() != null, InterviewConversation::getTitle, interviewConversation.getTitle());
        lqw.eq(interviewConversation.getStatus() != null, InterviewConversation::getStatus, interviewConversation.getStatus());
        Page<InterviewConversation> page = interviewConversationMapper.selectPage(pageQuery.build(), lqw);
        return TableDataInfo.build(page);
    }

    /**
     * 新增对话记录
     * 
     * @param interviewConversation 对话记录
     * @return 结果
     */
    @Override
    public int insertInterviewConversation(InterviewConversation interviewConversation) {
        return interviewConversationMapper.insert(interviewConversation);
    }

    /**
     * 修改对话记录
     * 
     * @param interviewConversation 对话记录
     * @return 结果
     */
    @Override
    public int updateInterviewConversation(InterviewConversation interviewConversation) {
        return interviewConversationMapper.updateById(interviewConversation);
    }

    /**
     * 批量删除对话记录
     * 
     * @param conversationIds 需要删除的对话记录主键
     * @return 结果
     */
    @Override
    public int deleteInterviewConversationByIds(Long[] conversationIds) {
        return interviewConversationMapper.deleteBatchIds(java.util.Arrays.asList(conversationIds));
    }

    /**
     * 删除对话记录信息
     * 
     * @param conversationId 对话记录主键
     * @return 结果
     */
    @Override
    public int deleteInterviewConversationById(Long conversationId) {
        return interviewConversationMapper.deleteById(conversationId);
    }
}